#ifndef UCWEB_IMAGE_JPEG2JPEG_H_
#define UCWEB_IMAGE_JPEG2JPEG_H_
#include "ucwebimage.h"

/*
#include <Magick++.h>
#include <jpeglib.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <sys/time.h>
#include <time.h>
#include "webp.h"

using namespace std;
using namespace Magick;
typedef struct info
{
  int width;
  int height;
   int stride;
  uint8_t* rgb;

  info():width(0), height(0), stride(0), rgb(NULL)
  {

  }

  ~info()
  {
    if(rgb) {
      free(rgb);
    }
  }

}jpeg_image_info_byjpegc;
*/
class ucwebImageJpeg2Jpeg
{
public:
  ucwebImageJpeg2Jpeg();
  ucwebImageJpeg2Jpeg(const char* filename, int quality, float percentage_resize, const char* outfile);
  ~ucwebImageJpeg2Jpeg();

  int DecompressByGm();
  int DecompressByJpeglib(bool resize);
  //int DecompressByEpeg();

  int ResizeByGm(bool quality);
  int ResizeByJpeg();
  //int ResizeByEpeg();
  
  int CompressByGm();

  int DecomGmResizeGmComGm();
  int DecomJpegResizeJpegComJpeg();

protected:



private:
  Magick::Image*    image;
  Magick::Blob*     blob;
  jpeg_image_info_byjpegc* output;

  int       quality_image;
  float     percentage_resize;
  int       done_webpimage_info;
  char      outfile[500];
  string    filename;
  struct    jpeg_compress_struct cinfo;
  struct    jpeg_error_mgr jerr;
  int       decom_jpeg_done;
};

#endif /*UCWEB_IMAGE_JPEG2JPEG_H_ */
